package o;

import android.animation.LayoutTransition;
import android.util.Log;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import o.nn.c;

class oa {
    private static boolean ˊ;
    private static LayoutTransition ˋ;
    private static Field ˎ;
    private static boolean ˏ;
    private static Method ॱ;

    static void ˊ(@NonNull ViewGroup viewGroup, boolean z) {
        int i = 0;
        if (ˋ == null) {
            ˋ = new LayoutTransition() {
                public boolean isChangingLayout() {
                    return true;
                }
            };
            ˋ.setAnimator(2, null);
            ˋ.setAnimator(0, null);
            ˋ.setAnimator(1, null);
            ˋ.setAnimator(3, null);
            ˋ.setAnimator(4, null);
        }
        LayoutTransition layoutTransition;
        if (z) {
            layoutTransition = viewGroup.getLayoutTransition();
            if (layoutTransition != null) {
                if (layoutTransition.isRunning()) {
                    ˎ(layoutTransition);
                }
                if (layoutTransition != ˋ) {
                    viewGroup.setTag(c.ʼ, layoutTransition);
                }
            }
            viewGroup.setLayoutTransition(ˋ);
            return;
        }
        viewGroup.setLayoutTransition(null);
        if (!ˏ) {
            try {
                ˎ = ViewGroup.class.getDeclaredField("mLayoutSuppressed");
                ˎ.setAccessible(true);
            } catch (NoSuchFieldException e) {
                Log.i("ViewGroupUtilsApi14", "Failed to access mLayoutSuppressed field by reflection");
            }
            ˏ = true;
        }
        if (ˎ != null) {
            try {
                i = ˎ.getBoolean(viewGroup);
                if (i != 0) {
                    ˎ.setBoolean(viewGroup, false);
                }
            } catch (IllegalAccessException e2) {
                Log.i("ViewGroupUtilsApi14", "Failed to get mLayoutSuppressed field by reflection");
            }
        }
        if (i != 0) {
            viewGroup.requestLayout();
        }
        layoutTransition = (LayoutTransition) viewGroup.getTag(c.ʼ);
        if (layoutTransition != null) {
            viewGroup.setTag(c.ʼ, null);
            viewGroup.setLayoutTransition(layoutTransition);
        }
    }

    private static void ˎ(LayoutTransition layoutTransition) {
        if (!ˊ) {
            try {
                ॱ = LayoutTransition.class.getDeclaredMethod("cancel", new Class[0]);
                ॱ.setAccessible(true);
            } catch (NoSuchMethodException e) {
                Log.i("ViewGroupUtilsApi14", "Failed to access cancel method by reflection");
            }
            ˊ = true;
        }
        if (ॱ != null) {
            try {
                ॱ.invoke(layoutTransition, new Object[0]);
            } catch (IllegalAccessException e2) {
                Log.i("ViewGroupUtilsApi14", "Failed to access cancel method by reflection");
            } catch (InvocationTargetException e3) {
                Log.i("ViewGroupUtilsApi14", "Failed to invoke cancel method by reflection");
            }
        }
    }
}
